Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate trigger form params to new UI #45270

Merged

Conversation

jscheffl
Copy link
Contributor

@jscheffl jscheffl commented Dec 29, 2024

After @shubhamraj-git has added the trigger form to the new React UI, this PR now adds the flexible trigger form - Based on the logic of the former AIP-50 implementation - using DAG ParamsDict to render form fields based on field definitions.

Note that the form rendering was made as a component by intent as it will be re-used in Connection Forms in future to render connection extra fields.

To test the form rendering the following DAGs might be good candidates:

  • example_bash_decorator - has no params so should not display a specific form
    image

  • example_bash_operator - has one basic parameter w/o any special thing. Simple as it can be
    image

  • example_params_trigger_ui - has 4 parameters, still basic
    image
    ... and with advanced section un-folded:
    image

  • example_params_ui_tutorial - this is the most complex beast as it has all features as a demo that shall be supported.
    image
    image
    ...and the lower section un-folded:
    image

Scope of the PR is the UI layout and logic to render. What is missing and will be a follow-up PR is the binding and sync of the form field content with the JSON dict that is used to trigger the DAG in the "Advanced Options" section.

@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Dec 29, 2024
@jscheffl jscheffl added the AIP-50 Trigger DAG UI user Form label Dec 29, 2024
@jscheffl jscheffl force-pushed the feature/migrate-trigger-form-params-to-new-ui branch from 51d3c4d to 83c450e Compare December 29, 2024 22:21
@shubhamraj-git
Copy link
Contributor

shubhamraj-git commented Dec 30, 2024

Thanks @jscheffl for working on this.
Had the first look. Looks great. The base is almost ready.

As mentioned in TODO, we will support the accordion and not flat.

Some points which i noticed, just writing it down incase we don't miss.

  1. There is no live changes to conf json onBlur
  2. Should have a validation for integer inputs.
  3. Dropdown not working for select values
  4. we should have a time picker.
  5. Length check not working
    6. JSON inputs should have a code view? (Just a opinion)
  6. List should have multi lines

Overall this is going in right direction.

Should we have inbuilt scroll for the dynamic form? since the modal seems very long.

EDIT: Just saw a todo for point 6 (json code view) and most of the above issues as todo.

@jscheffl jscheffl force-pushed the feature/migrate-trigger-form-params-to-new-ui branch 4 times, most recently from e7381e7 to 8067918 Compare January 2, 2025 15:41
@jscheffl
Copy link
Contributor Author

jscheffl commented Jan 2, 2025

Thanks @jscheffl for working on this. Had the first look. Looks great. The base is almost ready.

As mentioned in TODO, we will support the accordion and not flat.

Some points which i noticed, just writing it down incase we don't miss.

1. There is no live changes to conf json onBlur
2. Should have a validation for integer inputs.
3. Dropdown not working for select values
4. we should have a time picker.
5. Length check not working
   ~6. JSON inputs should have a code view? (Just a opinion)~
6. List should have multi lines

Overall this is going in right direction.

Should we have inbuilt scroll for the dynamic form? since the modal seems very long.

EDIT: Just saw a todo for point 6 (json code view) and most of the above issues as todo.

(1) I recommend to make into a separate PR - as also discussed 1:1
(2,3,5,6) fixed.
(4) would need a component fix in react for Chrome... and a workaround for Firefox. Firfox time picking is "just broken" - would make this to a separate PR as well.

So... for the Layout part I'd say... ready for review!

@jscheffl jscheffl marked this pull request as ready for review January 2, 2025 15:52
Copy link
Contributor

@shubhamraj-git shubhamraj-git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jscheffl ! Overall it looks good. Just few comments.
When clicking on trigger run, the modal pops up with all the options at front.
Should we consider them in a accordion and if needed user can view?
Apart from it, had some general comments, which is similar for all files.

@jscheffl jscheffl force-pushed the feature/migrate-trigger-form-params-to-new-ui branch from 8067918 to 313d868 Compare January 4, 2025 16:10
Copy link
Contributor

@shubhamraj-git shubhamraj-git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one glitch, which can be taken in further work.

Also, few things to add in list of TODO:

  1. Reset button should reset everything on the Form, including the flexible form, and it should ask a validation pop up, since if by mistake user press it, it's lot to loose.
  2. Accordion should be there for flexible form fields.
  3. And of course connection between conf and flexible form.

Copy link
Contributor

@bbovenzi bbovenzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I would argue against putting the form inside of an Accordion because it would hide required fields from the user.
Screenshot 2025-01-07 at 1 42 39 PM 2. Let's remove the `FlexibleForm` prefix from these components. It's too hard to read and is redundant with their parent folder.

@jscheffl jscheffl force-pushed the feature/migrate-trigger-form-params-to-new-ui branch 2 times, most recently from 6b61cf4 to fcbe5d0 Compare January 9, 2025 21:06
@jscheffl jscheffl force-pushed the feature/migrate-trigger-form-params-to-new-ui branch from fcbe5d0 to de1a47c Compare January 11, 2025 19:56
@jscheffl
Copy link
Contributor Author

Had a few "sleeps" over the discussion I had in Slack with @shubhamraj-git about Accordion.. and after Pierre also assigned it to the Note for Clear tasks... I am somewhat open and ajusted... as forms can get long. All is not (last commit) in one accordion group. Looks like this and parts are nicely folding:

image

Changing to Advanced options:

image

WDYT?

@jscheffl
Copy link
Contributor Author

Hi @bbovenzi I aligned in Slack with @shubhamraj-git that he would take the "wire-up" of reset-button and sync of form fields <-> Advanced Options JSON in a follow up PR the next days. So this PR is mainly the general component start and layout, function coming in the next PR.

Would it be OK frmo point of code/layout/structure mo merge? Then would need your review/approval.

Copy link
Contributor

@bbovenzi bbovenzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this took me a bit to review.

Now I see how sections work with the accordions so ignore my previous comment.

It is a bit of a nitpick, but coudl we rename the field components? Along the lines of NumberInput instead of FieldNumber?

I'm excited we're finally able to migrate all of this to react! Great work!

airflow/ui/src/components/FlexibleForm/SelectElement.tsx Outdated Show resolved Hide resolved
airflow/ui/src/queries/useDagParams.ts Outdated Show resolved Hide resolved
airflow/ui/src/components/FlexibleForm/SelectElement.tsx Outdated Show resolved Hide resolved
airflow/ui/src/components/FlexibleForm/index.tsx Outdated Show resolved Hide resolved
airflow/ui/src/components/FlexibleForm/index.tsx Outdated Show resolved Hide resolved
airflow/ui/src/components/FlexibleForm/Hidden.tsx Outdated Show resolved Hide resolved
airflow/ui/src/components/FlexibleForm/SelectElement.tsx Outdated Show resolved Hide resolved
@jscheffl jscheffl force-pushed the feature/migrate-trigger-form-params-to-new-ui branch from de1a47c to 1c43ce6 Compare January 14, 2025 22:39
@jscheffl
Copy link
Contributor Author

Sorry this took me a bit to review.

Now I see how sections work with the accordions so ignore my previous comment.

It is a bit of a nitpick, but coudl we rename the field components? Along the lines of NumberInput instead of FieldNumber?

I'm excited we're finally able to migrate all of this to react! Great work!

Uff, this was a very good review! Learned something new. I assume now it needs a second iteration review from the rework...
Had some challenges with the flex-basis - which is much cleaner in your proposal... but somehow not working. Any idea why?

Copy link
Contributor

@bbovenzi bbovenzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found two things with the datetime field.

Also, did you see my comment on renaming the Fields and NormalRow?

airflow/ui/src/components/FlexibleForm/FieldDateTime.tsx Outdated Show resolved Hide resolved
airflow/ui/src/components/FlexibleForm/FieldSelector.tsx Outdated Show resolved Hide resolved
@jscheffl jscheffl force-pushed the feature/migrate-trigger-form-params-to-new-ui branch from 1c43ce6 to 7028d76 Compare January 15, 2025 23:11
@jscheffl
Copy link
Contributor Author

Found two things with the datetime field.

Also, did you see my comment on renaming the Fields and NormalRow?

Next round of reviews applied.
Saw the request to rename "NormalRow" ... renamed it to proposed "FieldRow" - is this OK?
The other comment about renaming the Fields... I did not understand. Can you help me what you wanted me to rename to?

@jscheffl jscheffl requested a review from bbovenzi January 16, 2025 06:43
Copy link
Contributor

@bbovenzi bbovenzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this all looks pretty good. Let's get this merged and continue working on the rest

@jscheffl jscheffl merged commit 6d16136 into apache:main Jan 16, 2025
45 checks passed
dauinh pushed a commit to dauinh/airflow that referenced this pull request Jan 24, 2025
* Add flexible form fields to trigger form WIP

* Add flexible form fields to trigger form WIP

* Fix dropdown issue

* Add support for arrays of strings

* Add support for advanced arrays

* Remove placeholder for string

* Add support for proposals in string fields

* Add support for multi-select dropdowns

* Add support for object fields

* Add support for number fields

* Add support for multiline text fields

* Use other component for multi-select which displays the values

* Implement support for form sections

* Implement support for form sections

* Add an alert that form ist not fully implemented

* Review feedback - safe string handling

* Review feedback, remove reloading warnings, move selector functions to separate TSX file

* Review feedback - rename components for shorter name

* Review feedback - adjust hard-coded color for boder in CodeMirror

* Rework default field values

* Move form elements into a common accorion

* Review feedback

* Review feedback, next round

* Remove un-needed placeholders in date-time picker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AIP-50 Trigger DAG UI user Form area:UI Related to UI/UX. For Frontend Developers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants